//
//  StatusCell.swift
//  Weibo
//
//  Created by 张小东 on 16/1/17.
//  Copyright © 2016年 Mr.Zhang. All rights reserved.
//

import UIKit
import SnapKit

class StatusCell: UITableViewCell {
    
    var status: Status? {
        didSet {
            // 绑定数据
            // 设置原创微博的数据类型
            statusOriginalView.statuses = status
        }
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //设置UI
    private func setupUI() {
        backgroundColor = UIColor.yellowColor()
        
        contentView.addSubview(statusOriginalView)
        contentView.addSubview(statusCellBottomView)
     
        // 设置statusOriginalView的约束
        statusOriginalView.snp_makeConstraints { (make) -> Void in
            make.left.right.top.equalTo(contentView)
            // 仅用于测试
            
            //            make.height.equalTo(80)
        }
        
        //设置statusCellBottomView的约束
        statusCellBottomView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(statusOriginalView.snp_bottom)
            make.left.right.equalTo(contentView)
            make.height.equalTo(35)
        }
        
        
        // 给contentView 设置约束条件
        contentView.snp_makeConstraints { (make) -> Void in
            make.left.right.top.equalTo(self)
            // 设置自动计算行高最重要的一条约束
            
            make.bottom.equalTo(statusCellBottomView.snp_bottom)
        }
        
    }
    
    //懒加载子视图
    
    
    
    //如果从 xib / sb加载 会调用到这个方法
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    //原创微博
    private lazy var  statusOriginalView: StatusOriginalView = StatusOriginalView()
    // 评论按钮
    private lazy var statusCellBottomView: StatusCellBottomView = StatusCellBottomView()
}
